package com.bjesc_b2c.app.appraiset.widget.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.widget.BaseDialog;

/**
 * Created by yidong on 2017/6/13.
 */

public class InputPriceDialog extends BaseDialog implements View.OnClickListener {

    private InputPriceListener callBack;
    private EditText priceEdit;
    private Context context;
    public InputPriceDialog(Context context, InputPriceListener callBack) {
        super(context);
        this.callBack = callBack;
        this.context = context;
        initViews();
    }

    private void initViews() {
        view = inflater.inflate(R.layout.layout_input_price_dialog, null);
        view.findViewById(R.id.tv_cancel).setOnClickListener(this);
        view.findViewById(R.id.tv_sure).setOnClickListener(this);
        priceEdit = (EditText) view.findViewById(R.id.edit_car_price);
        setContentView(view);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_cancel:
                dismiss();
                break;
            case R.id.tv_sure:
                if (callBack != null) {
                    if (TextUtils.isEmpty(priceEdit.getText().toString())){
                        Toast.makeText(context,"请填写价格",Toast.LENGTH_SHORT).show();
                    }else {
                        callBack.priceCallBack(priceEdit.getText().toString());
                    }
                }
                dismiss();
                break;
        }
    }

    public interface InputPriceListener {
        void priceCallBack(String price);
    }
}